﻿"""Exception classes"""

class BaseError(Exception):
    """Base of all defined exception classes"""
    pass

class BadStatusCodeError(BaseError):
    """Raised when fetch receives http response with status code != 200."""
    def __init__(self, response):
        self.response = response
    def __str__(self):
        return "Bad status code code (" + str(response.status_code) +  ")"

class StopError(BaseError):
    """Base of all stop exception classes"""
    pass
    
class UnexistingStopError(BaseError):
    """Raised when there is no stop_number stop"""
    def __init__(self, stop_number):
        self.stop_number = stop_number
    def __str__(self):
        return "Unexisting stop (" + str(self.stop_number) +  ")"

class FieldValidationError(BaseError):
    """Base class for invalid form fields exceptions"""
    def __init__(self, field):
        self.field = field
    
class InvalidFieldStopError(FieldValidationError):
    """Invalid form field stop exception"""
    def __str__(self):
        return 'Invalid data in field stop.'

class InvalidFieldLineError(FieldValidationError):
    """Invalid form field line exception"""
    def __str__(self):
        return 'Invalid data in field line.'

class InvalidFieldTimeError(FieldValidationError):
    """Invalid form field time exception"""
    def __str__(self):
        return 'Invalid data in field time.'

class InvalidFieldPageNameError(FieldValidationError):
    """Invalid form field page name exception"""
    def __str__(self):
        return 'Invalid data in field page name.'
    